/**
 * res参数
 * 1、用来获取函数实参，代替arguments
 * 2、函数多个参数只能必须放在参数最后面
 */

function add(a, b, ...args) {
    console.log(args)
    return a + b
}

/***
   * 一：赋值
   */
const obj = {
    name: "小费",
    age: 23,
    title: {
        data: "时间简史",
        key: 12301
    },
    arr: [{
        name: "笑话"
    }],
    add: function (obj) {
        console.log("push对象进来。")
        this.arr.push(obj)
    }
}
const newObj = { ...obj }
console.log("旧对象：", obj)
console.log("新对象：", newObj)
newObj.add({ name: "小明", age: 25, sex: "男" })
/**
 * @description: 结构对象赋值
 * @param {*}
 * @return {*}
 */
const { name, age, title: { data, key } } = obj
console.log(`${name} - ${age} - ${data} - ${key}`)
/**
 * 2、扩展运算符合并对象
 * @type {{name: string, age: number}}
 */
const obj1 = {
    name: "小费",
    age: 23
}

const obj2 = {
    school: "二道渠小学",
    address: "甘肃省白银市靖远县五合乡二道渠村四社"
}
const obj3 = { ...obj1, ...obj2 }
console.log("合并的新对象obj3:", obj3)